package com.mytx.mapper;

import com.mytx.pojo.Coupon;
import com.mytx.pojo.CouponExample;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface CouponMapper {

    //自动批量更新方法，只更新状态字段，用于金币红包过期，批量更新
    void updateBatch(@Param(value = "list") List<Coupon> couponList);

    void updateBatch2(@Param(value = "list") List<Coupon> couponList,@Param(value = "status") Integer status);
    void updateBatch3(@Param(value = "list") List<Coupon> couponList);
    void updateBatch4(@Param(value = "list") List<Coupon> couponList);
    void updateBatch5(@Param(value = "list") List<Coupon> couponList,@Param(value = "status") Integer status);

    // 查询发出的总金额
    Double getSendTotalAmount(String uId);

    //查询收到的总金额
    Double getReceiveTotalAmount(String tId);

    List<Coupon> selectReceivedRecord(String tId);

    /**
     * 查询发出的红包
     * @param uId
     * @return
     */
    List<Coupon> selectSendRecord(String uId);
    /**
     * 查询一对多红包接收记录
     * @param parentCouponId  一对多红包id  (对应表中的 parentId)
     * @return
     */
    List<Coupon> selectChildCoupon(String parentCouponId);

    /**
     * 根据父红包id 和用户id，查询领取的子红包信息
     * @param parentCouponId 一对多红包id
     * @param uId  领取人id
     */
    Coupon selectChildCoupon_v1(@Param("parentCouponId")String parentCouponId, @Param("uId")String uId);

    /**
     * 查询一对一红包，并且返回接收方的用户信息
     * @param couponId
     * @return
     */
    Coupon selectSingleCoupon(String couponId);


//    =======================================================分界线===============================================================

    int countByExample(CouponExample example);

    int deleteByExample(CouponExample example);

    int deleteByPrimaryKey(String id);

    int insert(Coupon record);

    int insertSelective(Coupon record);

    List<Coupon> selectByExample(CouponExample example);

    Coupon selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") Coupon record, @Param("example") CouponExample example);

    int updateByExample(@Param("record") Coupon record, @Param("example") CouponExample example);

    int updateByPrimaryKeySelective(Coupon record);

    int updateByPrimaryKey(Coupon record);
}